package com.beamfield.controller.manage.lab;

import com.beamfield.common.ApiResult;
import com.beamfield.controller.common.BaseController;
import com.beamfield.enums.HttpResultEnum;
import com.beamfield.service.manage.lab.LabService;
import com.beamfield.service.manage.lab.LabStatisticsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;

/**
 * @author Zephyr
 * @Description: 试验室数据统计
 * @Date 2018/10/2
 */
@RequestMapping(value = "/cms/lab")
@Controller
public class LabController extends BaseController {
    @Autowired
    private LabStatisticsService labStatisticsService;

    @RequestMapping(value = "/statistics")
    public ModelAndView statistics(){
        return new ModelAndView();
    }

    @RequestMapping(value = "/engineering/opening")
    public ModelAndView opening(){
        return new ModelAndView();
    }

    @RequestMapping(value = "/engineering/concrete_mix_design")
    public ModelAndView concrete_mix_design(){
        return new ModelAndView();
    }

    @RequestMapping(value = "/engineering/geotechnical")
    public ModelAndView geotechnical(){
        return new ModelAndView();
    }

    @RequestMapping(value = "/getStatisticsData", method = RequestMethod.GET)
    @ResponseBody
    public ApiResult getStatisticsData(HttpServletRequest request){
        Long beamId = super.getBeamId(request);
        try{
            return labStatisticsService.getStatisticsData(beamId);
        }catch (Exception e){
            e.printStackTrace();
        }
        return new ApiResult(HttpResultEnum.EXCEPTION.getCode(), HttpResultEnum.EXCEPTION.getMessage());
    }
}
